﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.WebNemo.Data;

namespace blackhouse.WebNemo.Business.Groups {
    public class VirtualColumn {

        #region Properties

        public int VirtualId { get; private set; }
        public string ColumnName { get; private set; }
        public string Description { get; private set; }
        public bool HideForEdition { get; private set; }
        public string ViewControl { get; private set; }
        public string EditControl { get; set; }
        public int[] VirtualizeColumnsId { get; private set; }

        #endregion

        #region Constructors

        internal VirtualColumn(VirtualColumnData data) {
            this.VirtualId = data.VirtualId;
            this.ColumnName = data.ColumnName;
            this.Description = data.Description;
            this.HideForEdition = data.HideForEdition;
            this.ViewControl = data.ViewControl;
            this.EditControl = data.EditControl;

            string[] vci = data.VirtualizeColumnsId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            this.VirtualizeColumnsId = new int[vci.Length];
            for (int xvci = 0; xvci < vci.Length; xvci++) {
                this.VirtualizeColumnsId[xvci] = Int32.Parse(vci[xvci]);
            }
        }

        public override bool Equals(System.Object obj) {
            VirtualColumn p = obj as VirtualColumn;
            if ((object)p == null) {
                return false;
            }

            return this.VirtualId == p.VirtualId;
        }

        public bool Equals(VirtualColumn p) {
            return this.VirtualId == p.VirtualId;
        }

        public override int GetHashCode() {
            return this.VirtualId;
        }
        #endregion

    }
}
